<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        // prototype  原型对象
        //   每一个函数都有一个属性叫做 prototype  
        //   作用：为实例化对象提供共有的属性和方法  

        function Dog(name, age) {
            // const obj = {} ;
            // this -> obj
            // obj.name = name ;
            // obj.age = age ;
            this.name = name;
            this.age = age;

            // return obj ;
        }

        Dog.prototype.type = '狗子';

        Dog.prototype.say = function () {
            console.log('汪');
        }



        const d = new Dog('哈士奇', 2);

        const d2 = new Dog('柯基', 3);

        d.say();

        console.log(d);

        console.log(d.say === d2.say);


    </script>

</body>

</html>